﻿<?php require_once('../Connections/connect.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>WMA Grpah</title>
<script language="JavaScript" type="text/javascript" src="../jquery-1.7.min.js"></script>
<script type="text/javascript">
function showSelect(action){
	var txt_branch="&branch_id=" + $("#branch").val();
	var txt_zone="&zone_id=" + $("#zone").val();
	$.ajax({
		url: "combobox.php",
		type: "POST",
		async: false,
		cache: false,
		timeout: 2000,
		data: "action="+action+txt_branch+txt_zone,
		success: function(result){
			$(action).html(result);
		}
		
	});
}
</script>
<script type="text/javascript" src="../onclick.js"></script>
</head>
<body onload="drawChart();">
<h2>กราฟแสดงความยาวท่อส่งแยกตามวัสดุ</h2>
<form name="formname" method="post" action="graph_core.php">
	<div style="float:left;width:200px;">
    <select style="width:90%;" id="branch" name="branch" onchange="showSelect('#zone_div');showSelect('#DMA_div');">
    <option value="" selected="selected" > -------- เลือกสาขา -------- </option>
    <option value="0">สาขาทั้งหมด</option>
    <?php
		mysql_select_db($database_connect, $connect);
		$query_q = "SELECT * FROM mwa_area group by branch_id";
		$q = mysql_query($query_q, $connect) or die(mysql_error());
		while($row_q = mysql_fetch_array($q)){
		  $id = $row_q["branch_id"];
		  $name = $row_q["branch_name"];
	     echo"<option value='$id'>$name</option>";
		};
    ?>      
    </select>
    </div>
   	<div id="zone_div" style="float:left;width:150px;"><select style="width:90%;display:none;" name="zone" id="zone" onchange="showSelect('#DMA_div')"></select></div>
	<div id="DMA_div" style="float:left;width:150px;"><select style="width:90%;display:none;" name="DMA" id="DMA"></select></div>  
    <input name="btn_show" type="submit" id="btn_show" value="Show Graph"/>
	
</form>
	<!--<div id="chart_div" style="width: 900px; height: 500px;"></div>-->
</body>
</html>